package com.yan.demo;

import java.util.LinkedList;

public class Demo4 {
    public static void main(String[] args) {
        LinkedList list = new LinkedList();
        list.addFirst(10);
        list.addFirst(20);
        list.addLast(30);
        list.addLast(40);
        System.out.println(list);
        Object first = list.getFirst();
        System.out.println("first = " + first);
        System.out.println(list.getLast());
        list.offerFirst(100);
        System.out.println(list);
        list.offerLast(200);
        System.out.println("list = " + list);
        Object o = list.peekFirst();
        System.out.println("o = " + o);
        System.out.println("-------------------");
        Object pop = list.pop();
        System.out.println("pop = " + pop);
        System.out.println("list = " + list);
        Object o1 = list.pollFirst();
        System.out.println("o1 = " + o1);
        System.out.println(list);
        list.push(10);
        System.out.println(list);
        System.out.println(list.removeFirstOccurrence(10));
        System.out.println(list);
        // list.clear();
        list.addLast(30);
        System.out.println(list);
        list.removeLastOccurrence(30);
        System.out.println(list);
        list.add(10);
    }
}
